<template>
  <div class="pos-info">
    <p class="detail-title">
      其他信息<span class="btn" v-if="showView" @click="toggleView">编辑</span>
    </p>
    <div class="com-container" v-if="showView">
      <div class="show-item">
        <p class="department">
          <span>工作地点:</span>
          <span>{{ otherInfo.for_bumen }}</span>
        </p>
        <p class="major">
          <span>专业要求:</span>
          <span>{{ otherInfo.major }}</span>
        </p>
      </div>
    </div>
    <div class="com-form" v-else>
      <div class="postForm">
        <div class="form-item">
          <div class="text" required>工作地点:</div>
          <div class="input">
            <input
              v-model="otherInfo.for_bumen"
              type="text"
              placeholder="请输入工作地点"
            />
          </div>
        </div>
        <div class="form-item">
          <div class="text" required>专业要求:</div>
          <div class="input">
            <input
              v-model="otherInfo.major"
              type="text"
              placeholder="请输入专业要求"
            />
          </div>
        </div>
        <div class="submit">
          <button class="confirm" type="button" @click="submit">保存</button>
          <button class="cancel" type="button" @click="cancel">取消</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['info'],
  data () {
    return {
      showView: true,
      otherInfo: {
        for_bumen: '',
        major: '',
      },
    }
  },
  watch: {
    info(val) {
      this.otherInfo = val;
    }
  },
  created () {
    this.otherInfo = this.info;
  },
  mounted () {
  },
  methods: {
    toggleView () {
      this.showView = false;
    },
    toDelete (index) {
      this.list.splice(index, 1);
    },
    cancel () {
      this.showView = true;
    },
    submit () {
      this.showView = true;
    },
  }
}
</script>
<style lang="scss" scoped>
.pos-info {
  position: relative;
  .com-container {
    padding: 10px 0;
  }
  .show-item {
    line-height: 30px;
    padding-left: 20px;
    margin: 10px 0;
    & > p {
      display: inline-block;
      span {
        &:first-child {
          color: #999;
          margin-right: 10px;
        }
        &:last-child {
          color: #666;
        }
      }
    }
    .department {
      min-width: 300px;
    }
    .major {
      min-width: 210px;
    }
    
  }
  .com-form {
    padding: 30px 0;
    .postForm {
      width: 500px;
      margin: 0 auto;
      .form-item {
        margin-bottom: 10px;
        line-height: 40px;
        & > div {
          display: inline-block;
        }
        & > .text {
          position: relative;
          padding-left: 20px;
          min-width: 120px;
          color: #24292f;
          vertical-align: top;
          &[required] {
            &::before {
              content: '*';
              position: absolute;
              left: 0px;
              top: 0px;
              color: $base-color-danger;
            }
          }
        }
        .input {
          input {
            line-height: 28px;
            border: 1px solid #ccc;
            border-radius: 4px;
            padding: 0 10px;
            width: 350px;
            font-size: 16px;
            &:active,
            &:focus {
              border-color: $base-color;
            }
          }
        }
      }
      .submit {
        margin-top: 60px;
        text-align: center;
        button {
          height: 45px;
          width: 150px;
          margin: 0 20px;
          border: 1px solid $base-color;
          border-radius: 6px;
          font-size: 16px;
          &:hover {
            box-shadow: 0 0 6px 0 $base-color;
          }
        }
        .cancel {
          background: #fff;
          color: $base-color;
        }
        .confirm {
          background: $base-color;
          color: #fff;
        }
      }
    }
  }
}
</style>
